# -*- coding: utf-8 -*-
import re
import json
import requests
from bs4 import BeautifulSoup
import yaml

ss= """<center style="color: #000000; font-size: 11px; margin-bottom: 4px;">Trouble viewing this message? <a href="https://store.steampowered.com/email/AccountCreationEmailVerification?sparams=eJxdUF1LxDAQ_C998Emu-WjS5ODQ_-BroWy3G694TUKaeIj4302lgvg2OzM7w-5nc4Pi8Uopf0Rqzg1rHpuYwlwwe1h35iUTrJXdSowhZVphuVX6GJ-3XY7hTonmE4bdeZg28rlkrF6urNBCMymq-k5pcQtCXoIfS9qzrjnH7Ty0Q7vlkOj0P3NoATEUn4fW0_3Af3Oe6t4b-YsQRnOBVpFinPdGWzc5bnslSXWGKyZtJ9D0IKZJGIfWgeMSJoaoLXHgVk9O9swKR04y23V6AjBqBjlba8wDJvopXOaL7KQWvVFMSamVqkDX63xZxxUyXhf_Ov7-ijVf323KdjA">Click here.</a></center>
"""

# with open("./mail_content","r") as f:
#     htmlhandle = f.read()
#
# soup = BeautifulSoup(htmlhandle, 'html.parser')
#
# # 找出所有的 a 标签， 因为所有的链接都在 a 标签内
# data = soup.find_all('a')
#print data
#file = open('mail_content', mode='w')

# 遍历所有的 a 标签， 获取它们的 href 属性的值和它们的 text
for item in []:
    string = """
    <a href="https://store.steampowered.com/account/newaccountverification?stoken=228612c95e50117869fbf19753e5481503942c87a2bb28fc9faf13ab0cc69e1a196bf37092fef309446baa85da3d9988&amp;creationid=3436278505336558506" style="border-radius: 2px; padding: 1px; display: block; text-decoration: none; color: #D2E885; background: #799905; background: -webkit-linear-gradient( top, #799905 5%, #536904 95%);
	background: linear-gradient( to bottom, #799905 5%, #536904 95%);
text-shadow: -1px -1px 0px rgba( 0, 0, 0, 0.1 );">
<span style="border-radius: 2px; display: block; padding: 0; font-size: 20px; line-height: 32px; ">
											      Create My Account      
										</span>
</a>"""
   # result = re.findall(".*href=\"(.*)\" style.*", string)
   # print result
    #if item.string is not None and item['href'] != 'javascript:;' and item['href'] != '#':
    #    steam_mail = (item.string, item.get('href'))
        #print steam_mail
        #file.write(str.__add__(item.string, ' '))
        #file.write(str.__add__(item['href'], '\n'))

#print data
a = ["1",""]

data = {
    "accountname": "s6KzWURZ54",
    "password": "XfVL7ooul932",
    "count": 6,
    "lt": 0,
    "creation_sessionid": 3111251836739711440,
    "embedded_appid": 0
}
save_info_url = "https://store.steampowered.com/join/createaccount/"
# account_info = requests.post(save_info_url, data=data)
# if account_info:
#     result = account_info.content
#     result = json.loads(result)
#     if result:
#         print result
#         if result.get("bSuccess")=="bSuccess":
#             print "sxxxxxxxxxxxxxxxxx"
#         else:
#             print "===================="
server = ""
port = ""


with open("./config.yaml") as f:
    config = yaml.load(f, Loader=yaml.FullLoader)
    server = config["mail_server"]["choice"]
    port = config[server]["port"]
    server = config[server]["pop3_server"]


print server
print port
